<template>
  <div class="coupon_index">
    <!-- 优惠券列表展示 -->
    <div class="center">
      <div
        class="coupon"
        :class="[
          ele.couponTemplateInfo.couponType == 1 ? 'direct' : '',
          ele.couponTemplateInfo.couponType == 2 ? 'rate' : '',
          ele.couponTemplateInfo.couponType == 3 ? 'exchange' : '',
          ele.couponTemplateInfo.couponType == 4 ? 'carwash' : '',
          ele.couponTemplateInfo.couponType == 100 ? 'tongyong' : ''
        ]"
        v-for="ele in recordList"
        :key="ele.couponUserId"
        @click="gotoDetail(ele)"
      >
        <div class="left">
          <span v-if="ele.couponTemplateInfo.couponType === '1'">现金券</span>
          <span v-if="ele.couponTemplateInfo.couponType === '2'">折扣券</span>
          <span v-if="ele.couponTemplateInfo.couponType === '3'">兑换劵</span>
          <span v-if="ele.couponTemplateInfo.couponType === '4'">洗车券</span>
          <span v-if="ele.couponTemplateInfo.couponType === '100'">优惠券</span>
          <div class="exchangeName">
            {{ ele.couponTemplateInfo.couponName }}
          </div>
        </div>
        <div class="right">
          <p class="p1">
            优惠券类型:
            {{ ele.couponTemplateInfo.couponType === "1" ? "现金券" : "" }}
            {{ ele.couponTemplateInfo.couponType === "2" ? "折扣券" : "" }}
            {{ ele.couponTemplateInfo.couponType === "3" ? "兑换劵" : "" }}
            {{ ele.couponTemplateInfo.couponType === "4" ? "洗车券" : "" }}
            {{ ele.couponTemplateInfo.couponType === "100" ? "优惠券" : "" }}
          </p>
          <div class="infoItme">
            <p>优惠券额度: {{ele.couponTemplateInfo.couponType ==1? ele.couponTemplateInfo.couponAmt:ele.couponTemplateInfo.couponType==2?  `${ele.couponTemplateInfo.couponAmt}%`: "-" }}</p>
          </div>
          <div class="infoItme">
            <p>核销人：{{ ele.verificationUserAccount || "-" }}</p>
          </div>
          <div class="infoItme">
            <p>核销方式:{{ele.verificationType===1?'自助核销':ele.verificationType===2?'pos机核销':'-'}} </p>
            <p>核销张数：{{ ele.couponCount || "-" }}</p>
          </div>
          <p class="time">核销时间：{{ ele.verificationTime || "-" }}</p>
        </div>
      </div>
    </div>
    <!-- 空列表 -->
    <div
      v-if="recordList.length == 0"
      style="
        text-align: center;
        font-weight: bold;
        margin-top: 2rem;
        margin-bottom: 3rem;
      "
    >
      空空如也
    </div>

    <van-pagination
      v-show="total > 0"
      v-model="currentpage"
      :total-items="total"
      :items-per-page="queryForm.pageSize"
    />
  </div>
</template>
<script>
export default {
  head() {
    return {
      title:"核销记录"
    };
  },
  props: {
    recordList: {
      type: Array,
      default: () => []
    },
    queryForm: {
      type: Object,
      default: () => {}
    },
    total: {
      type: Number,
      default: 0
    },
    couponTypeOfUrl:{ 
      type:String,
      default:()=>{}
    },
    activeIndex:{
      type:Number,
      default:1
    }
  },
  watch: {
    currentpage(val) {
      let data = { ...this.queryForm };
      data.pageNum = val;
      this.$emit("update:queryForm", data);
      this.$emit("reloadCouponList");
    }
  },
  data() {
    return {
      currentpage: this.queryForm.pageNum
    };
  },
  methods: {
    // 去核销
    gotoDetail(item) {
      this.$router.push({
        path: `/${this.enterpriseId}/coupon/autoHexiao_detail`,
        query: { dataInfo: JSON.stringify(item),couponType:this.couponTypeOfUrl,activeIndex:this.activeIndex,stationId: this.queryForm.stationId }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.loading {
  width: 100px;
  height: 100px;
  position: fixed;
  top: 50%;
  left: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
}
.btnCheckbox {
  position: absolute;
  right: 0.2rem;
  top: 0rem;
  width: 0.5rem;
}
.coupon_index {
  width: 7.5rem;
  background: #ffffff;
  padding: 0 0.3rem 0 0.3rem;
  box-sizing: border-box;
  min-height: 100vh;
  margin-top: 0.3rem;

  > .top {
    width: 6.9rem;
    height: 1rem;

    .fixed {
      position: fixed;
      top: 0;
      left: 0;
      width: 7.5rem;
      height: 1rem;
      padding: 0 0.3rem 0 0.3rem;
      box-sizing: border-box;
      background: #ffffff;
      display: flex;
      justify-content: space-around;
      align-items: center;
      span {
        height: 0.45rem;
        font-size: 0.32rem;
        font-weight: 400;
        color: #aaaaaa;
        line-height: 0.45rem;
        letter-spacing: 0.01rem;
      }
      span.selected {
        color: #111111;
      }
    }
  }

  // 全选
  .checkAll {
    display: flex;
    align-items: center;
    justify-content: space-between;
    small {
      color: #666;
    }
  }
  > .center {
    .coupon {
      display: flex;
      justify-content: space-between;
      height: 2.8rem;
      margin-bottom: 0.3rem;
      box-shadow: 0rem 0rem 0.1rem 0.04rem rgba(233, 223, 223, 0.5);
      > .left {
        display: flex;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        width: 2.2rem;
        height: 2.8rem;
        text-align: center;

        span {
          color: #fff;
          font-size: 0.35rem;
        }

        .exchangeName {
          display: none;
          font-size: 0.35rem;
          font-weight: 500;
          color: #ffffff;
          line-height: 0.56rem;
        }
      }
      > .right {
        width: 4.56rem;
        height: 2.45rem;
        margin: 0.08rem 0 0.05rem 0;
        position: relative;
        box-sizing: content-box;
        padding: 0.1rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .p1 {
          font-size: 0.28rem;
        }
        > p {
          padding: 0;
          margin: 0;
          margin-bottom: 0.2rem;
        }
        .infoItme {
          display: flex;
          align-items: center;
          justify-content: space-between;
          color: #555;
          font-size: 0.25rem;
          margin-bottom: 0.1rem;
          p {
            margin: 0;
            padding: 0;
          }
        }
        .time {
          font-size: 0.28rem;
          color: #999;
          margin-bottom: 0px;
        }

        .content {
          display: flex;
          justify-content: space-between;
          margin: 0.05rem 0 0.05rem 0;
          height: 1.4rem;

          .items {
            width: 4.3rem;
            height: 100%;
            display: flex;
            justify-content: space-around;
            flex-direction: column;
            .item {
              color: #272626;
              font-size: 0.21rem;
              > span {
                width: 3.3rem;
                display: inline-block;
                color: #272626;
                font-size: 0.22rem;
                font-weight: bold;
                overflow: scroll; /* 超出部分隐藏 */
                white-space: nowrap; /* 文本不换行 */
              }
            }
            .from {
              display: block;
            }
          }
          > .btn {
            display: flex;
            flex-direction: column;
            justify-content: center;
            margin-right: 0.1rem;
            > button {
              height: 0.6rem;
              background: linear-gradient(143deg, #fad965 0%, #f3b235 100%);
              border-radius: 0.2rem;
              border: none;
              outline: none;
              color: #ffffff;
              line-height: 0.33rem;
              font-size: 0.3rem;
              font-weight: 400;
              overflow: hidden; /* 超出部分隐藏 */
              white-space: nowrap; /* 文本不换行 */
              display: none;
            }
          }
        }
        .notip {
          height: 1.8rem;
        }
        .tip {
          margin-right: 0.2rem;
          border-top: 0.02rem dashed #d8d8d8;
          height: 0.49rem;
          font-size: 0.22rem;
          font-weight: 400;
          color: #7f7f7f;
          line-height: 0.23rem;
          padding-top: 0.12rem;
          box-sizing: border-box;
          overflow: scroll; /* 超出部分隐藏 */
          white-space: nowrap;
          /*  text-overflow: ellipsis;*/
        }
      }
    }

    .tongyong {
      > .left {
        background: url("../../../static/coupon/quan6.png") no-repeat;
        background-size: 100% 100%;
      }

      > .right {
        > .title > .type {
          background: #19c79b;
        }

        > .content > .btn button {
          background: linear-gradient(143deg, #21d9b4 0%, #0fb582 100%);
          display: block;
        }
      }
    }

    .carwash {
      > .left {
        background: url("../../../static/coupon/quan5.2x.png") no-repeat;
        background-size: 100% 100%;
      }

      > .right {
        > .title > .type {
          background: #19c79b;
        }

        > .content > .btn button {
          background: linear-gradient(143deg, #21d9b4 0%, #0fb582 100%);
          display: block;
        }
      }
    }

    .direct {
      > .left {
        background: url("../../../static/coupon/quan1.2x.png") no-repeat;
        background-size: 100% 100%;
      }
      > .right {
        > .title > .type {
          background: #f8ce57;
        }
        > .content > .btn button {
          background: linear-gradient(143deg, #fad965 0%, #f3b235 100%);
        }
      }
    }
    .rate {
      > .left {
        background: url("../../../static/coupon/quan2.2x.png") no-repeat;
        background-size: 100% 100%;
      }
      > .right {
        > .title > .type {
          background: #eb8573;
        }
        > .content > .btn button {
          background: linear-gradient(143deg, #f4a796 0%, #e67462 100%);
        }
      }
    }
    .exchange {
      > .left {
        background: url("../../../static/coupon/quan3.2x.png") no-repeat;
        background-size: 100% 100%;
        > .amount,
        > .condition {
          display: none;
        }
        > .exchangeName {
          display: inline-block;
          width: 1.5rem;
          margin: 0 auto;
        }
      }
      > .right {
        > .title > .type {
          background: #19c79b;
        }
        > .content {
          > .items {
            width: 3.3rem;
            .item span {
              width: 2.3rem;
            }
          }
          > .btn button {
            background: linear-gradient(143deg, #21d9b4 0%, #0fb582 100%);
            display: block;
          }
        }
      }
    }
    .expired {
      > .left {
        background: url("../../../static/coupon/quan4.2x.png") no-repeat;
        background-size: 100% 100%;
      }
      > .right {
        > .title > .type {
          background: #bfbfbf;
        }
        > .content > .btn button {
          display: none;
        }
      }
    }
  }
  > .bottom {
    margin-top: 0.8rem;
    margin-bottom: 0.3rem;
    text-align: center;
    font-size: 0.22rem;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.25);
    line-height: 0.32rem;
    letter-spacing: 1px;
  }
}
.hidden-scroll::-webkit-scrollbar {
  display: none;
}
</style>
